/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lomanda
 */
@Entity
@Table(name = "contrato")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Contrato.findAll", query = "SELECT c FROM Contrato c"),
    @NamedQuery(name = "Contrato.findByIdContrato", query = "SELECT c FROM Contrato c WHERE c.idContrato = :idContrato"),
    @NamedQuery(name = "Contrato.findByData", query = "SELECT c FROM Contrato c WHERE c.data = :data"),
    @NamedQuery(name = "Contrato.findByTempo", query = "SELECT c FROM Contrato c WHERE c.tempo = :tempo"),
    @NamedQuery(name = "Contrato.findByDetalhes", query = "SELECT c FROM Contrato c WHERE c.detalhes = :detalhes")})
public class Contrato implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "data")
    @Temporal(TemporalType.DATE)
    private Date data;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idContrato")
    private Integer idContrato;
    @Basic(optional = false)
    @NotNull
    @Column(name = "tempo")
    private int tempo;
    @Size(max = 500)
    @Column(name = "detalhes")
    private String detalhes;
    @JoinColumn(name = "fkUsuario", referencedColumnName = "idUsuario")
    @ManyToOne(optional = false)
    private Usuario fkUsuario;
    @JoinColumn(name = "fkDepartamento", referencedColumnName = "idDepartamento")
    @ManyToOne(optional = false)
    private Departamento fkDepartamento;
    @JoinColumn(name = "fkFuncionario", referencedColumnName = "idFuncionario")
    @ManyToOne(optional = false)
    private Funcionario fkFuncionario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkContrato")
    private List<ProcessamentoSalario> processamentoSalarioList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkContrato")
    private List<HistoricoSalario> historicoSalarioList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkContrato")
    private List<Dividas> dividasList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "contrato")
    private List<AbonoContrato> abonoContratoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkContrato")
    private List<Ferias> feriasList;

    public Contrato() {
    }

    public Contrato(Integer idContrato) {
        this.idContrato = idContrato;
    }

    public Contrato(Integer idContrato, Date data, int tempo) {
        this.idContrato = idContrato;
        this.data = data;
        this.tempo = tempo;
    }

    public Integer getIdContrato() {
        return idContrato;
    }

    public void setIdContrato(Integer idContrato) {
        this.idContrato = idContrato;
    }

    public int getTempo() {
        return tempo;
    }

    public void setTempo(int tempo) {
        this.tempo = tempo;
    }

    public String getDetalhes() {
        return detalhes;
    }

    public void setDetalhes(String detalhes) {
        this.detalhes = detalhes;
    }

    public Usuario getFkUsuario() {
        return fkUsuario;
    }

    public void setFkUsuario(Usuario fkUsuario) {
        this.fkUsuario = fkUsuario;
    }

    public Departamento getFkDepartamento() {
        return fkDepartamento;
    }

    public void setFkDepartamento(Departamento fkDepartamento) {
        this.fkDepartamento = fkDepartamento;
    }

    public Funcionario getFkFuncionario() {
        return fkFuncionario;
    }

    public void setFkFuncionario(Funcionario fkFuncionario) {
        this.fkFuncionario = fkFuncionario;
    }

    @XmlTransient
    public List<ProcessamentoSalario> getProcessamentoSalarioList() {
        return processamentoSalarioList;
    }

    public void setProcessamentoSalarioList(List<ProcessamentoSalario> processamentoSalarioList) {
        this.processamentoSalarioList = processamentoSalarioList;
    }

    @XmlTransient
    public List<HistoricoSalario> getHistoricoSalarioList() {
        return historicoSalarioList;
    }

    public void setHistoricoSalarioList(List<HistoricoSalario> historicoSalarioList) {
        this.historicoSalarioList = historicoSalarioList;
    }

    @XmlTransient
    public List<Dividas> getDividasList() {
        return dividasList;
    }

    public void setDividasList(List<Dividas> dividasList) {
        this.dividasList = dividasList;
    }

    @XmlTransient
    public List<AbonoContrato> getAbonoContratoList() {
        return abonoContratoList;
    }

    public void setAbonoContratoList(List<AbonoContrato> abonoContratoList) {
        this.abonoContratoList = abonoContratoList;
    }

    @XmlTransient
    public List<Ferias> getFeriasList() {
        return feriasList;
    }

    public void setFeriasList(List<Ferias> feriasList) {
        this.feriasList = feriasList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idContrato != null ? idContrato.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contrato)) {
            return false;
        }
        Contrato other = (Contrato) object;
        if ((this.idContrato == null && other.idContrato != null) || (this.idContrato != null && !this.idContrato.equals(other.idContrato))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Contrato[ idContrato=" + idContrato + " ]";
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }
    
}
